<template>
  <el-card shadow="always" :body-style="{ padding: '20px' }">
    <template #header>
      <span>基本信息</span>
    </template>
    <el-descriptions title="" border="true" column="2">
      <el-descriptions-item label="医院名称" width="150">{{
        hospital.hosname
      }}</el-descriptions-item>
      <el-descriptions-item label="医院LOGO" width="150">
        <img
          :src="`data:image/png;base64,${hospital.logoData}`"
          width="100"
          height="100" />
      </el-descriptions-item>
      <el-descriptions-item label="医院编号">{{
        hospital.hoscode
      }}</el-descriptions-item>
      <el-descriptions-item label="医院地址">{{
        hospital.param.fullAddress
      }}</el-descriptions-item>
      <el-descriptions-item label="坐车路线" span="2">{{
        hospital.route
      }}</el-descriptions-item>
      <el-descriptions-item label="医院简介" span="2">{{
        hospital.intro
      }}</el-descriptions-item>
    </el-descriptions>
  </el-card>

  <el-card
    shadow="always"
    :body-style="{ padding: '20px' }"
    :style="{ marginTop: '20px' }">
    <template #header>
      <span>预约规则信息</span>
    </template>
    <el-descriptions title="" border="true" column="2">
      <el-descriptions-item label="预约周期" width="150"
        >{{ bookingRule.cycle }}天</el-descriptions-item
      >
      <el-descriptions-item label="放号时间" width="150"
        >{{ bookingRule.releaseTime }}
      </el-descriptions-item>
      <el-descriptions-item label="停挂时间">{{
        bookingRule.stopTime
      }}</el-descriptions-item>
      <el-descriptions-item label="退号时间">{{
        bookingRule.quitTime
      }}</el-descriptions-item>
      <el-descriptions-item label="医院编号" span="2">{{
        hospital.hoscode
      }}</el-descriptions-item>
    </el-descriptions>
  </el-card>
  <el-button
    type="primary"
    :style="{ marginTop: '20px' }"
    @click="router.push('/hospital/hospitalList')"
    >返回</el-button
  >
</template>

<script lang="ts">
import { reqGetHosDetail } from '@/api/hospital'
import { defineComponent, onMounted, ref } from 'vue'

export default defineComponent({
  name: 'HosDetail',
})
</script>

<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'

const route = useRoute()
const router = useRouter()
const bookingRule = ref({})
const hospital = ref({
  id: '',
  createTime: '',
  updateTime: '',
  isDeleted: 0 | 1,
  param: {
    hostypeString: '',
    fullAddress: '',
  },
  hoscode: '',
  hosname: '',
  hostype: '',
  provinceCode: '',
  cityCode: '',
  districtCode: '',
  address: '',
  logoData: '',
  intro: '',
  route: '',
  status: 0 | 1,
  bookingRule: null,
})

// 初始化发请求
onMounted(async () => {
  const { id }: any = route.query

  const result = await reqGetHosDetail(id)
  console.log(result)
  bookingRule.value = result.bookingRule
  hospital.value = result.hospital
})
</script>

<style scoped></style>
